package java.util.function;

/**
 * <p>Consumer</p>
 *
 * <p>项目名称：fakerMybatisPlusUtil</p>
 *
 * <p>注释:无</p>
 *
 * <p>Copyright: Copyright Faker(c) 2023/1/20</p>
 *
 * <p>公司: Faker</p>
 *
 * @author 淡梦如烟
 * @version 1.0
 * @date 2023/1/20 21:14
 */
public class Consumer<T> {

    /**
     * Performs this operation on the given argument.
     *
     * @param t the input argument
     */
    public void accept(T t){

    }

    /**
     * Returns a composed {@code Consumer} that performs, in sequence, this
     * operation followed by the {@code after} operation. If performing either
     * operation throws an exception, it is relayed to the caller of the
     * composed operation.  If performing this operation throws an exception,
     * the {@code after} operation will not be performed.
     *
     * @param after the operation to perform after this operation
     * @return a composed {@code Consumer} that performs in sequence this
     * operation followed by the {@code after} operation
     * @throws NullPointerException if {@code after} is null
     */
    public Consumer<T> andThen(final Consumer<? super T> after) {
        if (after == null){
            throw new NullPointerException();
        }
        return new Consumer<T>() {
            @Override
            public void accept(T t) {
                Consumer.this.accept(t);
                after.accept(t);
            }
        };
    }
}
